<template>
  <vol-box :lazy="true" v-model="model1" title="入库" :width="700" :padding="5" :onModelClose="onModelClose">
      <div style="height:400px;">
        <p v-html="model1Row">

            
        </p> 
          <!-- <p  v-html="formattedText">
             {{ model2RowFalut }}
              {{ JSON.stringify(model2RowFalut) }}
              <p v-html="formattedText"></p>
          </p> -->
      </div>
      <template #footer>
          <div>
              <!-- --><el-button type="primary" plain size="small" @click="callParent">入库确认</el-button> 
              <!-- <el-button type="primary" size="small" @click="closeModel1">确认</el-button> -->
              <el-button type="default" size="small" @click="model1 = false">关闭</el-button>
          </div>
      </template>
  </vol-box>
  <!-- 弹出框二 -->

</template>
<script>
import VolBox from '@/components/basic/VolBox.vue';
//这里使用的vue2语法，也可以写成vue3语法
export default {
  components: { 'vol-box': VolBox },
  methods: {},
  data() {
      return {
          model1: false,
          model1Rows: [], //弹出框1传入的选中行
          model2: false,
          model1Row: {},//弹出框2点击的当前行数据
        
      };
  },
  methods: {
      openModel1(rows) { //弹出框1
 
          this.model1Rows = rows;
          this.model1Row="刀:"+rows.tool_name+" "+"<br>"
          this.model1Row+="是否组装:"+rows.IsTogether+" "+"<br>"
          this.model1Row+="是否测量:"+rows.IsMeasure+" "+"<br>"
          this.model1Row+="对刀长度总:"+rows.IsTotallengthRange+" "+"<br>"
          this.model1Row+="刀长:"+rows.IsKnifeLengthRange+" "+"<br>"
          this.model1Row+="刀头直径:"+rows.IsKnifeDRange+" "+"<br>"
          this.model1Row+="刀柄长是否在范围:"+rows.IsHolderLenghtRange+" "+"<br>"
          this.model1Row+="刀柄半径是否在范围:"+rows.IsHolderRRange+" "+"<br>"
          this.model1Row+="是否在范围加长杆长:"+rows.IsAce1LenghtRange+" "+"<br>"
          this.model1Row+="是否在范围加长杆直径"+rows.IsAce1DRange+" "+"<br>";

          this.model1 = true;
      },
      openModel2(row, column, index) {//弹出框2
         // this.request1('sendlog', row);
       
      },
      openModel3(row, column, index) {//弹出框3 显示异常
      //    this.request1('Faultlog', row);
       
      },
      closeModel1() {
          this.model1 = false;
      },
      closeModel2() {
          this.model2 = false;
      },
      callParent() {
        let tigger = false;
      
                        this.$confirm(
                          "确认要入库【"+this.model1Rows.tool_name+"】吗？",
                          "警告",
                          {
                            confirmButtonText: "确定",
                            cancelButtonText: "取消",
                            type: "warning",
                            center: true,
                          }
                        ).then(() => {
                          debugger;
                          if (tigger) return;
                          tigger = true;
                       //   row.CurrentWriteValue = "True";
                    

                    this.$emit('parentCall', $parent => {  
                         $parent.request('PlcInStock', this.model1Rows);
                    //$parent就是生成页面的对象，比如可以调用页面刷新，可获取的属性与方法见【生成页面文档】,$parent.xxx直接调用
                    //调用刷新
                    $parent.search();
                    this.model1 = false;
                    //获取所有选中的行数据
                    // $parent.getSelectRows();
                    //  this.$message.success('调用了刷新')
                })

  
                        });
    
      },
      onModelClose() {
         // this.$message.success('弹出框右上角点击x关闭事件')
      },
      request1(action, row) {
   //   let url = `api/V_PLAN_WORK_ORDER/${action}`;
   let url = `A_UpperComputer/${action}`;
      this.http.post(url, row, true).then((result) => {
    debugger;
    if(action=='Faultlog'){
        this.model2Row= "";
    for (let [key, value] of Object.entries(result.data)) {

            this.model2Row+=value.createOn+" "+value.content+"<br>";
  // 执行循环体代码
}
    }
   
    this.$message.success('执行成功');
if(action=='sendlog'){
    
    this.model2Row = result.data;
}
  
        this.model2 = true;
     //   this.$message.success('执行成功');
       // this.search();
      });
    },
  }
};
</script>